package com.guangyunl.d_if;

import java.util.Scanner;

public class Demo08ElseIf {
    public static void main(String[] args) {
        // 创建对象
        Scanner sc = new Scanner(System.in);
        // 获取输入的年龄
        System.out.print("请输入一个年龄: ");
        int old = sc.nextInt();
        if (old < 0 || old > 130){
            System.out.println("该年龄不合常理，请重新输入年龄");
        }else {
            if (old >= 0 && old <= 6){
                System.out.println("该年龄" + old + "岁，为婴幼儿");
            } else if (old >= 7 && old <= 12) {
                System.out.println("该年龄" + old + "岁，为少儿");
            } else if (old >= 13 && old <= 17) {
                System.out.println("该年龄" + old + "岁，为青少年");
            } else if (old >= 18 && old <= 45) {
                System.out.println("该年龄" + old + "岁，为青年");
            } else if (old >= 46 && old <= 69) {
                System.out.println("该年龄" + old + "岁，为中年");
            } else if (old >= 69 && old <= 130) {
                System.out.println("该年龄" + old + "岁，为老年");
            }
        }
    }
}
